package com.wj.service.impl;

import com.wj.pojo.CustomWorks;
import com.wj.dao.CustomWorksMapper;
import com.wj.service.ICustomWorksService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wj.utils.RespUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wj
 * @since 2022-04-14
 */
@Service
public class CustomWorksServiceImpl extends ServiceImpl<CustomWorksMapper, CustomWorks> implements ICustomWorksService {
    @Resource
    private CustomWorksMapper customWorksMapper;

    @Override
    public void insertBackID(CustomWorks customWorks) {
        customWorksMapper.insert(customWorks);
    }

    @Override
    public RespUtil deleteWorks(Integer[] ids) {
        int i = customWorksMapper.deleteWorks(ids);
        if (i>0){
            return RespUtil.success("删除成功");
        }
        return RespUtil.error("删除失败");
    }

    @Override
    public List<CustomWorks> searchWorks(String searchText) {
        List<CustomWorks> searchWorks = customWorksMapper.searchWorks(searchText);
        searchWorks.forEach(v->{
            System.out.println(v);
        });
        return searchWorks;
    }
}
